package com.cskaoyan.shopping.controller;

import com.cskaoyan.mall.commons.result.ResponseData;
import com.cskaoyan.mall.commons.result.ResponseUtil;
import com.cskaoyan.shopping.dto.PanelContentDto;
import com.cskaoyan.shopping.dto.PanelDto;
import com.cskaoyan.shopping.dto.ProductCateDto;
import com.cskaoyan.shopping.service.IContentService;
import com.cskaoyan.shopping.service.IHomeService;
import com.cskaoyan.shopping.service.IProductCateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

/**
 * @Aurhor: 徐云飞
 * @DATE: 2022/10/25 16:50
 * @Description:商品主页显示
 * @Version 1.0
 */
@RestController
@RequestMapping("/shopping")
public class IHomeController {
    @Autowired
    IHomeService iHomeService;
    @Autowired
    IContentService iContentService;
    @Autowired
    IProductCateService iProductCateService;


    //商品主页显示
    @GetMapping("/homepage")
    public ResponseData homepage() {


        Set<PanelDto> homepage = iHomeService.homepage();

        return new ResponseUtil().setData(homepage);

    }

    //    导航显示
    @GetMapping("/navigation")
    public ResponseData navigation() {
        List<PanelContentDto> panelContentDtos = iContentService.queryNavList();

        return new ResponseUtil().setData(panelContentDtos);

    }

    //   获取所有商品种类
    @GetMapping("/categories")
    public ResponseData categories() {


        List<ProductCateDto> allProductCate = iProductCateService.getAllProductCate();



        return new ResponseUtil().setData(allProductCate);


    }


}
